#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import rospy
from std_msgs.msg import Int32  # 使用标准消息类型 Int32

def send_duoji(degree):
    """
    函数功能: 发布舵机旋转命令
    参数: degree - 整数值，表示舵机编号和角度
    """
    rospy.init_node('duoji_publisher', anonymous=True)
    duoji_pub = rospy.Publisher('duoji_topic', Int32, queue_size=10)
    rate = rospy.Rate(10)  # 10Hz

    while not rospy.is_shutdown():
        duoji_pub.publish(degree)
        rospy.loginfo(f"Published degree: {degree}")
        rate.sleep()

if __name__ == '__main__':
    try:
        send_duoji(3180)  # 传入旋转度数，例如 3180 表示舵机 3 转 180 度
    except rospy.ROSInterruptException:
        pass

